class Solution
{
public:
    bool digitCount(string num)
    {
        unordered_map<int, int> count;
        for (char c : num)
        {
            ++count[c - '0'];
        }
        int n = num.size();
        for (int i = 0; i < n; ++i)
        {
            if (num[i] - '0' != count[i])
            {
                return false;
            }
        }
        return true;
    }
};